package com.example.fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

public class SecondRvAd extends RecyclerView.Adapter<SecondRvAd.VH1> {

     String[] wenzi;
     int[] tupian;


public SecondRvAd(int[] tupian,String[] wenzi){
    this.tupian = tupian;
    this.wenzi = wenzi;
}

    static class VH1 extends RecyclerView.ViewHolder {
        TextView tvTwoRv;
        ImageView imgTwoRv;
        public VH1(@NonNull View itemView) {
            super(itemView);
            tvTwoRv = itemView.findViewById(R.id.tv_twoRv);
            imgTwoRv = itemView.findViewById(R.id.img_twoRv);
        }
    }


    @NonNull
    @Override
    public SecondRvAd.VH1 onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.tworv_item,parent,false);
        return new VH1(view);
    }

    @Override
    public void onBindViewHolder(@NonNull SecondRvAd.VH1 holder, int position) {
        holder.tvTwoRv.setText(wenzi[position]);
        holder.imgTwoRv.setImageResource(tupian[position]);
    }

    @Override
    public int getItemCount() {

        return tupian.length;
    }

}
